<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8" name="viewport"
    content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <title>
    <?php echo $config["websitename"] ?>
  </title>
  <!-- 新 Bootstrap 核心 CSS 文件 -->
  <link href="./file/css/bootstrap.min.css" rel="stylesheet">
  <script src="./file/js/pickduck.js"></script>
  <link href="./file/css/pickduck.css" rel="stylesheet">
  <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
  <script src="./file/js/jquery_2.1.1_jquery.min.js"></script>

  <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
  <script src="./file/js/bootstrap.min.js"></script>
  <script src="./file/js/jquery_2.1.4_jquery.min.js"></script>

  <script>

    $(document).ready(function () {
      $("#code").hide();
      $("#login").click(function () {
        $("#panel").slideDown();
      });
      $("#re").click(function () {
        if ($("#re").text() == "/注册") {
          $("#re").text('/登录');
          $("#lo").text('注册');
          $("#bbbbb").text('注册');
          $("#code").show();
        } else {
          $("#re").text('/注册');
          $("#lo").text('登录');
          $("#bbbbb").text('登录');
          $("#code").hide();
        }
      });
      $("#send").click(function () {
        $("#send").text("发送中");
        if ($("#email").val() != "") {
          //alert($("#email").val());
          $.get("./?path=function&page=code&mode=send&to=" + $("#email").val(), function (data, status) {
            $("#send").text("发送验证码");
            if (Number(data.code) == 200 && status == "success") {
              /*
              $("#send").text("已发送");
              setTimeout(function() {
                $("#send").text("发送验证码");
              }, 5000);
              */
              var email=new PickduckModal("发送成功", "若没有收到请查看垃圾箱哦",null,null);
              email.setDisplay(true);
            } else {
              var email=new PickduckModal("发送失败", "请耐心等待一会儿哦",null,null);
              email.setDisplay(true);
            }
          });
        } else {
          var email=new PickduckModal("发送失败", "请输入邮箱地址哦",null,null);
          email.setDisplay(true);
        }
      });
      $('#bbbbb').click(function () {
        // 在这里执行 bbbbb 函数的代码
        if ($("#bbbbb").text() == "注册") {
          $.get("./?path=function&page=signup&email=" + $("#email").val() + "&text=" + $("#input_code").val() + "&password=" + $("#password").val(), function (data, status) {
            var jsonStr = data; // 定义一个JSON字符串
            var jsonObj = JSON.parse(jsonStr); // 解析JSON字符串为对象
            var code = jsonObj.code;
            if (code == 200) {
              var sign=new PickduckModal("注册成功", "欢迎您的加入",null,null)
              sign.setReturnPickduckModalInput('sign',null,'text-right2')
              sign.setDisplay(true)
            } else if (code == 502) {
              var sign=new PickduckModal("注册失败", "该邮箱已被注册",null,null)
              sign.setDisplay(true)
            } else if (code == 402) {
              var sign=new PickduckModal("注册失败", "验证码已超时",null,null)
              sign.setDisplay(true)
            } else if (code == 401) {
              var sign=new PickduckModal("注册失败", "请点击“发送验证码”",null,null)
              sign.setDisplay(true)
            } else if (code == 404) {
              var sign=new PickduckModal("注册失败", "验证码输入错误，请检查一下哦",null,null)
              sign.setDisplay(true)
            }
          });
        } else {
          $.get("./?path=function&page=login&email=" + $("#email").val() + "&password=" + $("#password").val(), function (data, status) {
            var jsonStr = data; // 定义一个JSON字符串
            var jsonObj = JSON.parse(jsonStr); // 解析JSON字符串为对象
            var code = jsonObj.code;
            if (Number(code) == 200) {
              var login=new PickduckModal("登录成功", "欢迎回来",null,null)
              login.setReturnPickduckModalInput('login',null,'text-right2')
              login.setDisplay(true)
            } else if (code == 400) {
              var login=new PickduckModal("登录失败", "密码输入错误",null,null)
              login.setDisplay(true)
            }else if (code == 404) {
              var login=new PickduckModal("登录失败", "没有此用户",null,null)
              login.setDisplay(true)
            }
          });
        }
      });

    });

  </script>
  <style>
    .nav {
      position: fixed;
      top: 0px;
      z-index: 1;
      color: black;
      background-color: white;
      width: 100%;
      height: 60px;
      padding: 5px;
      box-shadow: 4px 4px 15px grey;
      display: flex;
      align-items: center;
    }

    .nav a {
      color: black;
      margin-right: 12.5vh;
      text-align: center;
    }

    .nav big {
      margin-right: 15vh;
      margin-left: 7.5vh;
    }

    html,
    body {
      width: 100%;
      height: 100%;
    }

    body {
      background-color: #97bfff;
    }

    a {
      text-decoration: none;
    }

    * {
      margin: 0px;
    }

    .png {
      width: 100%;
      height: 600px;
      /*text-align:center;*/
    }

    .png button {
      background-color: #0052D9;
      color: white;
      width: 100px;
      height: 40px;
      border-width: 0;
    }

    .buu {
      background-color: #0052D9;
      color: white;
      width: 70px;
      height: 40px;
      border-width: 0;
    }

    .png span {
      position: absolute;
      top: 61px;
      width: 100%;
      height: 600px;
      /*background-image: url("hero2-bg-pc1_160.jpg");
    background-size:cover;*/
      background-repeat: no-repeat;
      position: flex;
      z-index: -1;
      background-color: #97bfff;
    }
 .blocka {
    border-radius: 10px;
    width: 100%;
    height: 150px;
    display: inline-block;
    margin: 10px;
    text-align: center;
    background: linear-gradient(180deg, #e0e6ff 0%, #fff 100%);
    border: 2px solid #fff;
    box-shadow: 0px 3px 20px #5555;
    transition: all 0.3s ease-in-out;
    font-size: 12px;
    cursor: pointer;
}

    .da {
      display: flex;
    }

    @media screen and (max-width: 930px) {
      .blocka {
        border-radius: 10px;
        width: 100%;
        height: 150px;
        display: block;
        background-color: white;
        margin: 10px;
        text-align: center;
      }

      .da {
        display: block;
      }
    }

    #panel {
      display: none;
      padding: 20vh;
    }

    #panel div {
      backdrop-filter: blur(15px);
      /*模糊*/
      border-radius: 20px;
      /* 圆角*/
      width: 500px;
      height: auto;
    }
  </style>
</head>

<body>
  <div class="nav">
    <br><b>
      <big>
      <a href="./">
        <?php echo $config["websitename"] ?>
        </a>
      </big>
      <?php
      foreach ($bluestar->get_nav($conn) as $nav) {
        $url = $nav["url"];
        $name = $nav["name"];
        echo <<<_
        <a href="$url">
        $name
        </a>
        _;
      }
        if($user_info==false){
          echo <<<_
            <a id="login" style="margin:0;float:right">
              登录/注册
            </a>
          _;
        }else{
          $user_email = $user_info["email"];
          echo <<<_
          <a id="user_img" href="./?path=page&page=me" style="margin:0;float:right">
          $user_email
          </a>
          _;
        }
       ?>

    </b>
  </div>
  <div style="text-align:center;background-color:grey;position:fixed;bottom:0px;width:100%;z-index:1;">
    <p>© <?php
    $d = date("Y");
      if($d==="2023"){
        echo $d;
      }else{
        echo "2023-" . $d;
      }
     ?> blue star-net版权所有！</p>
  </div>
  <div id="panel"
    style="white-space: nowrap;top:60px;background-size:cover;background-image:url('./file/image/m.png');position:fixed;width:100%;height:100%;z-index:1;">
    <center>
      <div>
        <br>
        <h1 style="white-space: nowrap;"><b id="lo">登录</b><b id="re" style="color:green;font-size:20px;">/注册</b></h1>
        <p style="font-size:20px;white-space:nowrap;">邮箱: <input type="text" id="email" /></p>
        <p style="font-size:20px;white-space:nowrap;">密码: <input type="password" id="password" /></p>
        <script>

        </script>
        <p style="font-size:20px;white-space:nowrap;" id="code">验证码: <input type="text" id="input_code" /><button
            style="font-size:15px;color:white;width:auto;height:35px;" class="buu" id="send">发送验证码</button></p>
        <button class="buu" id="bbbbb">登录</button>
        <br><br>
      </div>
    </center>
  </div><?php
require("./app/page/pickduck.html");
?></body>

</html>